home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / infobots / Backup / MSOCache / All Users / 90000409-6000-11D3-8CFE-0150048383C9 / Q2561411.CAB / POWERPNT.EXE / RCDATA / 5920 < prev    next >
Text File  |  2003-07-30  |  12KB  |  480 lines

  1.  
  2. /*********************************************
  3.  Animation implementation
  4. **********************************************/
  5. var AE_NONE = 0, AE_DIM = 1, AE_HIDE = 2, AE_HIDEIMDTLY = 3, LONG_INTERVAL = 10, SHORT_INTERVAL = 5, g_curAnim = null, g_vml = 0;
  6.  
  7. function ParseAnimations(){
  8.     nr = document.all.tags("DIV").length;
  9.     while(nr > 0) {
  10.         rObj = document.all.tags("DIV").item(--nr);
  11.         if(rObj.style.cssText != null) {
  12.             build = rObj.style.cssText.indexOf("mso-build");
  13.             if(build >= 0)
  14.                 AddAnimation(rObj);
  15.         }
  16.     }
  17.     var delay=-1;
  18.     if(IsWin("PPTSld"))
  19.         delay = GetSldList().mList[parent.gCurSld - 1].mAdvDelay;
  20.     if( delay>=0 ) {
  21.         totT=0, autoAnims=0;
  22.         rAnims=g_animManager.m_anims;
  23.         nBuilds=g_animManager.m_numBuilds;
  24.         for(x=nBuilds;x>0;x--)
  25.         if(-1 != rAnims[x].m_secs){
  26.             totT+=rAnims[x].m_secs;
  27.             autoAnims++;
  28.         }
  29.         time=delay-totT;
  30.         if(time<0) time=0;
  31.         time=time/(nBuilds-autoAnims+1);
  32.         for(x=nBuilds;x>0;x--)
  33.             if(-1 == rAnims[x].m_secs)
  34.                 rAnims[x].m_secs=time;
  35.     }
  36. }
  37.  
  38. function AddAnimation(rObj){
  39.     a =new Animation();
  40.     a.m_obj =rObj;
  41.     a.m_oldc =rObj.color;
  42.     GetVal=rObj.style.getAttribute;
  43.     var t;
  44.     if( t=GetVal("mso-build") ) a.m_build=t-0;
  45.     if( t=GetVal("mso-build-after-action") ) a.m_aAct=t-0;
  46.     if( t=GetVal("mso-build-after-color") ) a.m_oldc=t;
  47.     if( t=GetVal("mso-build-auto-secs") ) a.m_secs=t-0;
  48.     if( t=GetVal("mso-build-avi") ) a.m_video=t;
  49.     if( t=GetVal("mso-build-dual-id") ) a.m_dId=t;
  50.     if( t=GetVal("mso-build-order") ) a.m_order=t-0;
  51.     if( t=GetVal("mso-build-sound-name") ) a.m_sound=t;
  52.  
  53.     g_animManager.AddAnimation(a);
  54. }
  55.  
  56. function ShowVGXObj(rObj){
  57.     vmlId=null,ImgTag=null;
  58.     curObj=rObj;
  59.     sObj =document.all.item("SlideObj");
  60.     while(null == ImgTag && null != curObj && sObj != curObj){
  61.         ImgTag =curObj.children.tags("IMG").item(0);
  62.         curObj =(curObj.parentElement.tagName == "DIV") ? curObj.parentElement : null
  63.     }
  64.     if(null !=ImgTag)
  65.         vmlId =ImgTag.getAttribute("v:shapes");
  66.     if(null !=vmlId) {
  67.         idx =vmlId.indexOf(",");
  68.         if(idx > 0) vmlId =vmlId.substr(0, idx);
  69.         vgxObj =document.all.item(vmlId);
  70.         if((null != vgxObj) && (null != vgxObj.parentElement) && (vgxObj.parentElement.style.display != "none")){
  71.             vgxObj.parentElement.style.visibility = "visible";
  72.             ImgTag.style.visibility = "hidden";
  73.         }
  74.         else
  75.             rObj.style.visibility = "visible";
  76.     }
  77. }
  78.  
  79. /*********************************************
  80.  AnimationManager class
  81. **********************************************/
  82. function AnimationManager(){
  83.     t=this;
  84.     t.m_anims=new Array();
  85.     t.m_numBuilds=0;
  86.     t.m_activeObj=null;
  87.     t.m_curBuild=1;
  88.     t.m_timer=-1;
  89.     t.m_objToHide=null;
  90.     t.m_objToDim=null;
  91.     t.m_colorToDim=-1;
  92.     t.m_isPlaying=0;
  93.     t.m_autoTimer=-1;
  94.     t.Peek=AM_Peek;
  95.     t.Next=AM_Next;
  96.     t.Previous=AM_Previous;
  97.     t.AddAnimation=AM_AddAnimation;
  98.     t.ShowShapes=AM_ShowShapes;
  99.     t.Swap=AM_Swap;
  100. }
  101.  
  102. function AM_ShowShapes(){
  103.     for(x=this.m_numBuilds; x>0; x--){
  104.         if(g_vml)
  105.             ShowVGXObj(this.m_anims[x].m_obj);
  106.         aObj =this.m_anims[x].m_obj;
  107.         if(aObj)
  108.             aObj.style.visibility = "visible";
  109.     }
  110.     this.m_numBuilds =0;
  111. }
  112.  
  113. function AM_Swap(cur){
  114.     rList =this.m_anims;
  115.     t =rList[cur+1];
  116.     rList[cur+1] =rList[cur];
  117.     rList[cur] =t;
  118. }
  119.  
  120. function AM_AddAnimation(a){
  121.     this.m_anims[++this.m_numBuilds] = a;
  122.     this.m_curBuild =this.m_numBuilds;
  123.     cur =this.m_numBuilds;
  124.     if(a.m_order > 0){
  125.         while(cur-- > 1 && Math.abs(this.m_anims[cur+1].m_order) > Math.abs(this.m_anims[cur].m_order))
  126.             this.Swap(cur);
  127.     }
  128.     else {
  129.         while(cur-- > 1 && Math.abs(this.m_anims[cur+1].m_order) >= Math.abs(this.m_anims[cur].m_order))
  130.             this.Swap(cur);
  131.     }
  132. }
  133.  
  134. function AM_Peek(){
  135.     if(g_animManager.m_curBuild > 0 && 0 < g_animManager.m_numBuilds) {
  136.         secs =g_animManager.m_anims[g_animManager.m_curBuild].m_secs;
  137.         if(secs != -1)
  138.             g_animManager.m_autoTimer = window.setTimeout("_DocAction()", secs);
  139.     }
  140.     // Check if need to auto advance the slide
  141.     else 
  142.         AutoAdv();
  143. }
  144.  
  145. function AM_Next(){
  146.     if(0 == this.m_numBuilds || (g_curAnim != null)) return 0; 
  147.     success=0;
  148.     if(this.m_autoTimer != -1)
  149.         window.clearTimeout(this.m_autoTimer);
  150.     if(this.m_objToHide != null)
  151.         this.m_objToHide.style.visibility = "hidden";
  152.     if(this.m_objToDim != null) {
  153.         nr = document.all.length;
  154.         while(nr-- > 0) {
  155.             rObj =document.all.item(nr);
  156.             if(this.m_objToDim.contains(rObj))
  157.                 rObj.style.color = this.m_colorToDim;
  158.         }
  159.     }
  160.     if(this.m_curBuild > 0) {
  161.         this.m_activeObj =this.m_anims[this.m_curBuild--];
  162.         this.m_activeObj.Start();
  163.         success =1;
  164.     }
  165.     return success;
  166. }
  167.  
  168. function AM_Previous(){
  169.     if((null == g_curAnim) && (this.m_curBuild <= this.m_numBuilds)) {
  170.         this.m_curBuild++;
  171.         var animObj = this.m_anims[this.m_curBuild];
  172.         if(this.m_curBuild >= 1)
  173.             animObj.m_obj.style.visibility = "hidden";
  174.     }
  175. }
  176.  
  177. function InitBuildEffects(){
  178.     g_animManager =new AnimationManager();
  179.     ParseAnimations();
  180.     isFullScreen =(window.name == "PPTSld") && !parent.IsFramesMode();
  181.     if(!g_showAnimation || (isFullScreen && parent.IsSldVisited()))
  182.         g_animManager.ShowShapes();
  183.     else if(!SldHasTrans())
  184.         g_animManager.Peek();
  185.     if(isFullScreen && !g_isKiosk)
  186.         parent.SetSldVisited();
  187.     SlideObj.onfilterchange = g_animManager.Peek;
  188. }
  189.  
  190.  
  191. /*********************************************
  192.  Animation class
  193. **********************************************/
  194. function Animation(){
  195.     t=this;
  196.     t.m_obj=0;
  197.     t.m_build=0;
  198.     t.m_dId="";
  199.     t.m_aAct=0;
  200.     t.m_secs=-1;
  201.     t.m_order=0;
  202.     t.m_sound="";
  203.     t.m_oldc=0;
  204.     t.m_video="";
  205.     t.m_animObj=0; 
  206.     t.m_timer=-1;
  207.     t.m_steps=0;
  208.     t.m_finalL=0;
  209.     t.m_finalT=0;
  210.     t.m_finalW=0;
  211.     t.m_finalH=0;
  212.     t.Start=A_Start;
  213.     t.End=A_End;
  214.     t.Animate=A_Animate;
  215.     t.SetupMove=A_SetupMove;
  216.     t.DoMove=A_DoMove;
  217.     t.DoSpiral=A_DoSpiral;
  218.     t.DoSwivel=A_DoSwivel;
  219.     t.DoInplace=A_DoInplace;
  220. }
  221.  
  222. function TickHandler(){
  223.     if(null != g_curAnim) g_curAnim.Animate();
  224. }
  225.  
  226. function GetAnimClass(dir){
  227.     if(dir > 99) return 7; 
  228.     else if(dir > 28) return 5; 
  229.     else if(dir == 27) return 4; 
  230.     else if(dir == 28) return 3; 
  231.     else if((dir >= 12) && (dir < 16))return 2; 
  232.     else return 1; 
  233. }
  234.  
  235. function GetSteps(dir){
  236.     animClass =GetAnimClass(dir);
  237.     if(animClass == 5 || animClass == 7) return 1; 
  238.     res=12;
  239.     if(animClass >= 2 && animClass <= 4) res = 50;
  240.     if(SlideObj.style.backgroundImage != "") res /= 2;
  241.     return res;
  242. }
  243.  
  244. function A_Start(){
  245.     g_curAnim = this;
  246.     this.SetupMove();
  247.     if(this.m_sound)
  248.         PlaySound(this.m_sound, false);
  249.     animClass =GetAnimClass(this.m_build);
  250.     if(5 == animClass)
  251.         this.DoInplace();
  252.     else {
  253.         this.m_animObj.style.visibility = "visible";
  254.         time = 0;
  255.         if(7 == animClass) { 
  256.             // Appear and flash
  257.             switch(this.m_build) {
  258.                 case 100: time = 300; break;
  259.                 case 101:
  260.                 case 200: time = 500; break;
  261.                 case 102: time = 1000; break;
  262.             }
  263.             if(this.m_build < 200)
  264.                 this.m_aAct = AE_HIDEIMDTLY;
  265.         }
  266.         else
  267.             time =(animClass % 2 == 0) ? LONG_INTERVAL : SHORT_INTERVAL;
  268.         this.m_timer =window.setInterval("TickHandler()", time);
  269.     }
  270. }
  271.  
  272. function A_End(){
  273.     window.clearInterval(this.m_timer);
  274.     if(this.m_video != "")
  275.         PlayMedia(this.m_video);
  276.     rStyle = this.m_obj.style;
  277.     if(this.m_dId == ""){
  278.         rStyle.pixelLeft =this.m_finalL;
  279.         rStyle.pixelTop =this.m_finalT;
  280.         rStyle.pixelWidth    =this.m_finalW;
  281.         rStyle.pixelHeight =this.m_finalH;
  282.     }
  283.     else {
  284.         if(this.m_aAct != AE_HIDEIMDTLY)
  285.             rStyle.visibility = "visible";
  286.         this.m_animObj.style.visibility = "hidden";
  287.     }
  288.     switch(this.m_aAct){
  289.         case AE_NONE: 
  290.             if(g_vml)
  291.                 ShowVGXObj(this.m_obj);
  292.             break;
  293.         case AE_DIM:
  294.             if(g_vml)
  295.                 ShowVGXObj(this.m_obj);
  296.             g_animManager.m_objToDim    =this.m_obj;
  297.             g_animManager.m_colorToDim    =this.m_oldc;
  298.             break;
  299.         case AE_HIDE:
  300.             g_animManager.m_objToHide    =this.m_obj;
  301.             break;
  302.         case AE_HIDEIMDTLY:
  303.             rStyle.visibility ="hidden";
  304.             break;
  305.     }
  306.     if(this.m_dId != "")
  307.         this.m_animObj.style.visibility ="hidden";
  308.     if(!g_animManager.m_isPlaying){
  309.         g_curAnim = null;
  310.         this.m_obj = null;
  311.         g_animManager.Peek();
  312.     }
  313. }
  314.  
  315. function A_Animate(){
  316.     switch(GetAnimClass(this.m_build)) {
  317.         case 1:
  318.         case 2: this.DoMove();    break;
  319.         case 3: this.DoSpiral();    break;
  320.         case 4: this.DoSwivel();    break;
  321.     }
  322.     if(--this.m_steps == 0) 
  323.         this.End();
  324. }
  325.  
  326. function A_SetupMove(){
  327.     dir =this.m_build;
  328.     this.m_steps =GetSteps(dir);
  329.     rObj =this.m_dId != "" ? document.all.item(this.m_dId) : this.m_obj;
  330.     this.m_animObj =rObj;
  331.     offsetL=0;
  332.     offsetT=0;
  333.     parentObj=rObj.parentElement;
  334.     while(parentObj.tagName != "BODY" && parentObj.id != "SlideObj"){
  335.         offsetL    +=parentObj.offsetLeft;
  336.         offsetT    +=parentObj.offsetTop;
  337.         parentObj =parentObj.parentElement; 
  338.     }
  339.     rStyle = rObj.style;
  340.     this.m_finalL =sLeft =rStyle.pixelLeft;
  341.     this.m_finalT =sTop =rStyle.pixelTop;
  342.     this.m_finalW =sWidth =rStyle.pixelWidth;
  343.     this.m_finalH =sHeight =rStyle.pixelHeight;
  344.     clientW=SlideObj.style.pixelWidth-offsetL;
  345.     clientH=SlideObj.style.pixelHeight-offsetT;
  346.      if(dir < 100) {
  347.         switch(dir) {
  348.             case 0: case 12: sLeft=-(sWidth+offsetL); break;
  349.             case 1: case 13: sTop=-(sHeight+offsetT);    break;
  350.             case 2: case 14: sLeft=clientW; break;
  351.             case 3: case 15: sTop=clientH; break;
  352.             case 4: 
  353.                 sLeft=-(sWidth+offsetL); 
  354.                 sTop=-(sHeight+offsetT); 
  355.                 break;
  356.             case 5: 
  357.                 sLeft=clientW; 
  358.                 sTop=-(sHeight+offsetT); 
  359.                 break;
  360.             case 6: 
  361.                 sLeft=-(sWidth+offsetL); 
  362.                 sTop=clientH; 
  363.                 break;
  364.             case 7: 
  365.                 sLeft=clientW; 
  366.                 sTop=clientH; 
  367.                 break;
  368.             case 8: sLeft-=sWidth; break;
  369.             case 9: sTop+=sHeight; break;
  370.             case 10: sLeft+=sWidth; break;
  371.             case 11: sTop-=sHeight; break;
  372.             case 16:
  373.                 sLeft+=sWidth/2;
  374.                 sTop+=sHeight/2;
  375.                 sWidth=0;
  376.                 sHeight=0;
  377.                 break;
  378.             case 17:
  379.                 sLeft+=sWidth/6;
  380.                 sTop+=sHeight/6;
  381.                 sWidth=sWidth*2/3;
  382.                 sHeight=sHeight*2/3;
  383.                 break;
  384.             case 18:
  385.                 sLeft-=(3*sWidth)/2;
  386.                 sTop-=(3*sHeight)/2;
  387.                 sWidth=sWidth*4;
  388.                 sHeight=sHeight*4;
  389.                 break;
  390.             case 19:
  391.                 sLeft-=sWidth/6;
  392.                 sTop-=sHeight/6;
  393.                 sWidth=sWidth*4/3;
  394.                 sHeight=sHeight*4/3;
  395.                 break;
  396.             case 20:
  397.                 sLeft=clientW/2;
  398.                 sTop=clientH/2;
  399.                 sWidth=0;
  400.                 sHeight=0;
  401.                 break;
  402.             case 21:
  403.                 sLeft= 0; 
  404.                 sTop=clientH; 
  405.                 sWidth=clientW; 
  406.                 sHeight=clientH;
  407.                 break;
  408.             case 22:
  409.                 sLeft+=sWidth/2;
  410.                 sWidth=0;
  411.                 break;
  412.             case 23: sWidth=0; break;
  413.             case 24: sHeight=0; break;
  414.             case 25:
  415.                 sLeft+=sWidth;
  416.                 sWidth=0;
  417.                 break;
  418.             case 26:
  419.                 sTop+=sHeight;
  420.                 sHeight=0;
  421.                 break;
  422.             case 27:
  423.                 sLeft+=sWidth/2;
  424.                 sWidth=0;
  425.                 break;
  426.             case 28:
  427.                 sLeft=0;
  428.                 sTop=clientH;
  429.                 sWidth=0;
  430.                 sHeight=0;
  431.                 break;
  432.         }
  433.     }
  434.     if(0 == sWidth) 
  435.         sWidth++;
  436.     rStyle.pixelLeft=sLeft;
  437.     rStyle.pixelTop=sTop;
  438.     rStyle.pixelWidth=sWidth;
  439.     rStyle.pixelHeight=sHeight;
  440. }
  441.  
  442. function A_DoInplace(){
  443.     if(this.m_animObj.filters.revealtrans){
  444.         this.m_animObj.filters.revealtrans.Apply();
  445.         this.m_animObj.style.visibility ="visible";
  446.         this.m_animObj.filters.revealtrans.Play();
  447.     }
  448. }
  449.  
  450. function A_DoMove(){
  451.     rStyle = this.m_animObj.style;
  452.     rStyle.pixelLeft +=(this.m_finalL - rStyle.pixelLeft)/this.m_steps;
  453.     rStyle.pixelTop +=(this.m_finalT - rStyle.pixelTop)/this.m_steps;
  454.     rStyle.pixelWidth +=(this.m_finalW - rStyle.pixelWidth)/this.m_steps;
  455.     rStyle.pixelHeight +=(this.m_finalH - rStyle.pixelHeight)/this.m_steps;
  456.  
  457. function A_DoSpiral(){
  458.     ratio =this.m_steps / GetSteps(this.m_build);
  459.     angle =2*ratio*3.14;
  460.     cosa =Math.cos(angle);
  461.     sina =Math.sin(angle);
  462.     vx =(this.m_finalL + this.m_finalW / 2)*ratio;
  463.     vy =(this.m_finalT + this.m_finalH / 2 - SlideObj.style.pixelHeight) * ratio;
  464.     rStyle =this.m_animObj.style;
  465.     rStyle.pixelLeft =this.m_finalL - vx * cosa - vy * sina;
  466.     rStyle.pixelTop =this.m_finalT + vx * sina - vy * cosa;
  467.     rStyle.pixelWidth =this.m_finalW * (1 - ratio);
  468.     rStyle.pixelHeight =this.m_finalH * (1 - ratio);
  469. }
  470.  
  471. function A_DoSwivel(){
  472.     rStyle =this.m_animObj.style;
  473.     angle =this.m_steps / GetSteps(this.m_build) * 5 * 3.14 / 2;
  474.     difX =Math.abs(this.m_finalW * Math.cos(angle));
  475.     rStyle.pixelLeft =this.m_finalL + (this.m_finalW - difX) / 2;
  476.     if(0 == difX) difX++;
  477.     rStyle.pixelWidth =difX;
  478. }
  479.